package Java基础;

import java.util.ArrayList;
 import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

public class a250411 {

    //定义一个集合添加数据过滤奇数并保存下来
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        Collections.addAll(list,1,2,3,4,5,6,7,8,9,10);
        List<Integer> newlist = list.stream()
                .filter(s -> s % 2 == 0)
                .collect(Collectors.toList());
        System.out.println(newlist);
    }
}
